<template>
    <div class="bottom-box">
        <titleComponent title="项目管控"></titleComponent>
        <el-button type="primary" class="down-btn" icon="el-icon-download" @click="down">导出</el-button>
        <div class="center">
            <img src="@/assets/img/bg.png" class="bg1" />
            <img src="@/assets/img/bg.png" class="bg2" />
            <img src="@/assets/img/bg.png" class="bg3" />
            <div class="center-box" v-for="item, i in list">
                <img src="../../../assets/img/img2.png" />
                <div class="content pointer" @click="goLink('/projectTable', item.type)">
                    <div class="name">{{ item.name }}</div>
                    <div class="value">{{ item.value }}</div>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
import titleComponent from "./titleComponent";
import moment from 'moment'
export default {
    components: {
        titleComponent,
    },
    watch: {
        mgr(val, oldVal) {
            if (val !== oldVal) {
                this.list = [
                    { name: "项目总数", value: val && val.totalMgr ? val.totalMgr : 0, type: 'totalIncome' },
                    { name: "在途项目", value: val && val.ztPro ? val.ztPro : 0, type: 'ZT_PRO' },
                    { name: "已结项项目", value: val && val.yjxPro ? val.yjxPro : 0, type: 'YJX_PRO' },
                    { name: "在途商机", value: val && val.xsShangJi ? val.xsShangJi : 0, type: 'XS_SHANG_JI' },
                    { name: "待预立项项目", value: val && val.dyLxPro ? val.dyLxPro : 0, type: 'DY_LX_PRO' },
                    { name: "预立项未中标", value: val && val.ylProNone ? val.ylProNone : 0, type: 'YL_PRO_NONE' },
                    { name: "中标待立项", value: val && val.zbDlx ? val.zbDlx : 0, type: 'ZB_DLX' },
                    { name: "立项待签约", value: val && val.lxDqy ? val.lxDqy : 0, type: 'LX_DQY' },
                    { name: "交付待验收", value: val && val.jfDys ? val.jfDys : 0, type: 'JF_DYS' }
                ]
            }
        }
    },
    props: {
        mgr: {
            type: Object,
            default: () => { },
        },
        orgId: {
            type: String,
            default: ''
        },
        yearFilter: {
            type: String,
            default: ''
        },
    },
    data() {
        return {
            list: [
                { name: "项目总数", value: this.mgr && this.mgr.totalMgr ? this.mgr.totalMgr : 0, type: 'totalIncome' },
                { name: "在途项目", value: this.mgr && this.mgr.ztPro ? this.mgr.ztPro : 0, type: 'ZT_PRO' },
                { name: "已结项项目", value: this.mgr && this.mgr.yjxPro ? this.mgr.yjxPro : 0, type: 'YJX_PRO' },
                { name: "在途商机", value: this.mgr && this.mgr.xsShangJi ? this.mgr.xsShangJi : 0, type: 'XS_SHANG_JI' },
                { name: "待预立项项目", value: this.mgr && this.mgr.dyLxPro ? this.mgr.dyLxPro : 0, type: 'DY_LX_PRO' },
                { name: "预立项未中标", value: this.mgr && this.mgr.ylProNone ? this.mgr.ylProNone : 0, type: 'YL_PRO_NONE' },
                { name: "中标待立项", value: this.mgr && this.mgr.zbDlx ? this.mgr.zbDlx : 0, type: 'ZB_DLX' },
                { name: "立项待签约", value: this.mgr && this.mgr.lxDqy ? this.mgr.lxDqy : 0, type: 'LX_DQY' },
                { name: "交付待验收", value: this.mgr && this.mgr.jfDys ? this.mgr.jfDys : 0, type: 'JF_DYS' }
            ]
        }
    },
    methods: {
        goLink(path, type) {
            this.$router.push({ path, query: { cityCode: this.orgId == '10008' ? '' : this.orgId, type, yearFilter: this.yearFilter } });
            // window.open(`/#${path}?cityCode=${this.orgId == '10008' ? '' : this.orgId}`)
        },
        down() {
            let endTime = ''; 
            if (this.yearFilter === String(new Date().getFullYear())) {
                endTime = moment().format('YYYY-MM-DD')
            } else {
                endTime = this.yearFilter + '-12-31'
            }
            let params = this.orgId === '10008' ? `?provinceCode=${this.orgId}&beginPreProjectDate=${this.yearFilter == 'all' ? '' : this.yearFilter + '-01-01'}&endPreProjectDate=${this.yearFilter == 'all' ? '' : endTime}` : `?cityCode=${this.orgId}&beginPreProjectDate=${this.yearFilter == 'all' ? '' : this.yearFilter + '-01-01'}&endPreProjectDate=${this.yearFilter == 'all' ? '' : endTime}`
            window.open(`/api/incomeQuestion/exportIncomeList${params}`)
        }
    }
}
</script>
<style lang="scss" scoped>
.bottom-box {
    background: #fff;
    width: 100%;
    height: 454px;
    box-sizing: border-box;
    padding: 16px;
    position: relative;
}

.down-btn {
    position: absolute;
    right: 16px;
    top: 12px;
    padding: 8px 14px;
}

.bg1 {
    position: absolute;
    top: 128px;
    left: 18px;
}

.bg2 {
    position: absolute;
    top: 255px;
    left: 18px;
}

.bg3 {
    position: absolute;
    top: 387px;
    left: 18px;
}

.center {
    display: flex;
    flex-wrap: wrap;
    margin-top: -12px;
}

.center-box {
    display: flex;
    margin-top: 40px;
    width: 33.3%;
    flex-wrap: wrap;
    padding-left: 30px;
    box-sizing: border-box;
    position: relative;

    img {
        margin-left: 10px;
        margin-right: 20px;
        width: 70px;
        height: 90px;
    }

    .value {
        font-size: 22px;
        color: #0a1b2e;
        font-weight: bold;
    }
}

.name {
    font-size: 18px;
    margin-top: 30px;
}

.pointer {
    cursor: pointer;
}
</style>